/*
 * Copyright © 2020-2021 尛飛俠（Denvie） All rights reserved.
 */

package cn.denvie.springboot.druid.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * JdbcController。
 *
 * @author Denvie
 * @date 2021/7/3
 * @since 1.0.0
 */
@RestController
@RequestMapping
public class JdbcController {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @GetMapping("/deptList")
    public List<Map<String, Object>> deptList() {
        String sql = "select * from dept";
        return jdbcTemplate.queryForList(sql);
    }

    @GetMapping("/employeeList")
    public List<Map<String, Object>> employeeList() {
        String sql = "select * from employee";
        return jdbcTemplate.queryForList(sql);
    }
}
